//
//  GTBasicViewController.swift
//  swiftWEIbo
//
//  Created by mac－gt on 15/11/23.
//  Copyright © 2015年 mac－gt. All rights reserved.
//

import UIKit

class GTBasicViewController: UITableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    let isLogin=GTAcounts.isLogin()
    override func loadView() {
        
        isLogin ? super.loadView():setUpView()
    }
    func setUpView()
    {
        view=vistorView
      vistorView.vistorViewDelegate=self
        view.backgroundColor=UIColor(white: 237/255.0, alpha: 1)
        if self is GTHomeViewController{
           vistorView.tranAnimation()
            NSNotificationCenter.defaultCenter().addObserver(self, selector: "appForeground", name: UIApplicationDidBecomeActiveNotification, object: nil)
            NSNotificationCenter.defaultCenter().addObserver(self, selector: "appBackground", name: UIApplicationDidEnterBackgroundNotification, object: nil)
        }else if self is GTMessageViewController
        {
               vistorView.changeViewImage("visitordiscover_image_message", lableContent: "在这里您可以时刻接受到别人发给你的消息")
        
        }else if self is GTDiscover{
             vistorView.changeViewImage("visitordiscover_image_message", lableContent: "在这里您可以时刻接受到别人发给你的消息,啦啦啦啦啦啦啦啦")
        }else if self is GTProfileViewController
        {
             vistorView.changeViewImage("visitordiscover_image_profile", lableContent: "在这里您可以时刻看到自己的状态设置")
        }
     
        navigationItem.leftBarButtonItem=UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
        navigationItem.rightBarButtonItem=UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
    }
    func appForeground(){
        vistorView.resumeAnimation()
    }
    func appBackground(){
        vistorView.pauseAnimation()
    }
    private lazy var vistorView: GTVistorView={
        let vistor=GTVistorView()
        return vistor
    }()
    deinit{
        if self is GTHomeViewController{
            NSNotificationCenter.defaultCenter().removeObserver(self)
        }
    }
}
extension GTBasicViewController: GTVistorViewDelegate{
    func vistorViewRegister() {
        print("你点击了注册按钮")
    }
    func vistorViewLogin() {
    presentViewController(UINavigationController(rootViewController:GTLoginController() ), animated: true) { () -> Void in
        }
    }
}
//

